package auxiliares;

public class Date {
    private int day;

    private int month;

    private int year;

    // *****************//
    // ** Constructor **//
    // *****************//
    public Date(final int day, final int month, final int year) {
        this.day = day;
        this.month = month;
        this.year = year;
    }

    // *************************//
    // ** Getters and Setters **//
    // *************************//
    public int getDay() {
        return this.day;
    }

    public int getMonth() {
        return this.month;
    }

    public int getYear() {
        return this.year;
    }

    // *************//
    // ** Metodos **//
    // *************//

    public boolean equals(final Date d) {
        return this.day == d.getDay() && this.month == d.getMonth() && this.year == d.getYear();
    }

    public boolean minor(final Date aDate) {
        boolean result = false;
        if (this.equals(aDate)) {
            return false;
        }
        if (this.year < aDate.getYear()) {
            result = true;
        } else {
            if (this.year == aDate.getYear() && this.month < aDate.getMonth()) {
                result = true;
            } else {
                if (this.month == aDate.getMonth() && this.day <= aDate.getDay()) {
                    result = true;
                }
            }
        }
        return result;
    }

    public boolean major(final Date aDate) {
        return !this.minor(aDate);
    }
    
  	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Date other = (Date) obj;
		if (day != other.day)
			return false;
		if (month != other.month)
			return false;
		if (year != other.year)
			return false;
		return true;
	}

	@Override
    public String toString() {
        return this.getDay() + "/" + this.getMonth() + "/" + this.getYear();
    }
}
